Skip to content

Conversation

michaelbynum
Copy link
Contributor

Summary/Motivation:

This PR extracts the code for detecting changes in models from the persistent solver interfaces to its own, independent functionality. I will have a separate PR shortly that removes the code from the solver interfaces and updates them to use this code.

Changes proposed in this PR:

  • add a module to contrib called observer that can be used to inform other classes of what changed in a pyomo model.

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 82.19697% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.17%. Comparing base (756c2c1) to head (d718e9a).

Files with missing lines Patch % Lines
pyomo/contrib/observer/model_observer.py 81.74% 90 Missing ⚠️
pyomo/contrib/observer/component_collector.py 88.57% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3695      +/-   ##
==========================================
- Coverage   89.20%   89.17%   -0.04%     
==========================================
  Files         892      894       +2     
  Lines      103018   103546     +528     
==========================================
+ Hits        91894    92332     +438     
- Misses      11124    11214      +90     
Flag Coverage Δ
builders 26.67% <17.42%> (-0.05%) ⬇️
default 85.75% <82.19%> (?)
expensive 33.99% <17.42%> (?)
linux 86.92% <82.16%> (-2.01%) ⬇️
linux_other 86.92% <82.16%> (-0.03%) ⬇️
osx 83.26% <82.16%> (-0.01%) ⬇️
win 85.14% <82.16%> (-0.01%) ⬇️
win_other 85.14% <82.16%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

obs.add_parameters(params)

def _check_for_new_vars(self, variables: List[VarData]):
new_vars = {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't enough to make new_vars a list and append non referenced variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think also this pattern is repeated multiple times.

@mrmundt mrmundt self-requested a review August 19, 2025 18:39
from pyomo.contrib.observer.model_observer import (
Observer,
ModelChangeDetector,
AutoUpdateConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There aren't actually any tests that exercise AutoUpdateConfig. There also isn't any documentation that shows how to use it. Can you add a test (that can act as documentation)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants